package com.ldk.api;

/**
 * 
 * @author xiangwl
 *
 */
public class ResponseError {
	private String type;
	private String code;
	private String message;
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	
	public static ResponseError build(String type, String code, String message)
	{
		ResponseError error = new ResponseError();
		error.setType(type);
		error.setCode(code);
		error.setMessage(message);
		
		return error;
	}
	
	public static ResponseError build(ErrorCode errorCode)
	{
		ResponseError error = new ResponseError();
		
		error.setType(errorCode.getType());
		error.setCode(String.format("%04d", errorCode.getCode()));
		error.setMessage(errorCode.getMessage());
		
		return error;
	}
	
	
}
